package com.hzcx.app.simplechat.ui.login.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.LoginModel;
import com.hzcx.app.simplechat.model.PublicModel;
import com.hzcx.app.simplechat.model.SettingModel;
import com.hzcx.app.simplechat.ui.login.bean.LoginInfoBean;
import com.hzcx.app.simplechat.ui.login.contract.BindPhoneContract;
import com.hzcx.app.simplechat.ui.login.contract.LoginContract;
import com.hzcx.app.simplechat.ui.publicui.bean.ProtocolBean;

public class BindPhonePresenter extends BasePresenter<BindPhoneContract.View> implements BindPhoneContract.Presenter {

    /**
     *  发送验证码
     * @param context
     * @param mobile
     * @param event
     * @param area_code
     */
    @Override
    public void sendCode(Context context, String mobile, String event, String area_code) {
        PublicModel.sendCode(context, mobile, event, area_code, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.sendCodeSuccess();
            }
        });
    }

    /**
     *  绑定手机号
     * @param context
     * @param token
     * @param mobile
     * @param captcha
     * @param area_code
     */
    @Override
    public void bindPhone(Context context, String token, String mobile, String captcha, String area_code) {
        SettingModel.updatePhone(context, token, mobile, captcha, area_code, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.bindSuccess();
            }
        });
    }

    /**
     *  获取协议内容
     * @param context
     * @param type
     */
    @Override
    public void getProtocol(Context context, String type) {
        PublicModel.getProtocolByType(context, type, new BaseDialogObserver<ProtocolBean>(context) {
            @Override
            protected void onSuccess(ProtocolBean data) {
                mView.protocolResult(data);
            }
        });
    }
}
